package com.tarry;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 自定义事件监听
 * 事件监听器，对事件进行处理或者转发、必须注册在事件源上
 */
@Component
public class MyListener implements ApplicationListener<MyEvent> {

    //对事件进行监听处理,对消息进行接收并处理
    public void onApplicationEvent(MyEvent myEvent) {
        String msg = myEvent.getMsg();
        System.out.println(" get the my event msg is : " + msg);
    }
}
